#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int minimumDeletions(string word, int k) {
        vector<int> letter(26, 0);
        for (auto& c : word)
        {
            ++letter[c - 'a'];
        }
        int res = INT_MAX;
        for (int i = 0; i < 26; i++)
        {
            int change = 0;
            for (auto& e : letter)
            {
                if (e == 0)
                    continue;
                if (e < letter[i])
                    change += e;
                else if (e > letter[i] + k)
                    change += (e - (letter[i] + k));
            }
            res = min(res, change);
        }
        return res;
    }
};